
#include "utils.h"
#include <stdarg.h>

#if defined(_WIN32)
  #include <direct.h>
  #ifndef getcwd
    #define getcwd _getcwd
  #endif
  #ifndef vsnprintf
    #define vsnprintf _vsnprintf
  #endif
#else
  #include <unistd.h>
#endif



// class CStdFile

bool CStdFile::Open(const char *filename, const char *mode)
{
    Close();

    if (filename == NULL || mode == NULL || (f=fopen(filename, mode)) == NULL)
    {
        char cwd[256];
        
        getcwd(cwd, 255);
        XTRACE("[CStdFile::Open] Failed. filename = \"%s\", mode = \"%s\", cwd = \"%s\"\n", filename, mode, cwd);
        return false;
    }

    return true;
}


const char *ft(const char *format, ...)
{    
    static char buffer[2048];
    va_list args;    

    va_start(args, format);
    vsnprintf(buffer, 2047, format, args);
    va_end(args);          

    return buffer;
}

